maxn = -1000000
num = []
dp = {}
a = int(input("请输入你要输入的数字个数："))
for i in range(a):
    num.append(int(input()))
dp[0] = num[0]
for i in range(1,a):
    dp[i] = max(num[i],dp[i-1]+num[i])
for i in range(a):
    maxn = max(dp[i],maxn)
print(maxn)